//包租合同接口
import exp from 'constants'
import axios, {ResponseData} from 'yuxin-base/src/utils/axios'

// 获取列表数据
export const charterContractList = (data: any): Promise<ResponseData> => {
	return axios.request({
		url: '/contract/enter_contract/get_enter_contract_list_page',
		data,
		method: 'POST'
	})
}
// 获取总账单
export const getTotalBillById = (enterContractId: any): Promise<ResponseData> => {
	return axios.request({
		url: `/finance/finance_bill/getTotalBillById/${enterContractId}`,
		method: 'GET'
	})
}
// 获取总数
export const getCharterContractCount = (data: any): Promise<ResponseData> => {
	return axios.request({
		url: '/contract/enter_contract/get_enter_contract_count',
		data,
		method: 'POST'
	})
}

/** 获取企业合同关联合同 */
export const getList = (data: any): Promise<ResponseData> => {
	return axios.request({
		url: '/contract/enter_contract/get_list',
		data,
		method: 'POST'
	})
}

/** 获取企业合同父合同关联合同 */
export const getBeforeRenewalList = (id: string): Promise<ResponseData> => {
	return axios.request({
		url: `/contract/enter_contract/get_before_renewal_list/${id}`,
		method: 'GET'
	})
}

/** 根据企业合同id获取所有关联合同下的所有子合同 */
export const getPageByEnterprise = (data: any): Promise<ResponseData> => {
	return axios.request({
		url: '/basesearch/contract_doc/page_by_enterprise',
		data,
		method: 'POST'
	})
}

//获取企业合约详情
export const getEnterContractDetails = (id: string): Promise<ResponseData> => {
	return axios.request({
		url: `/contract/enter_contract/get_enter_contract_details/${id}`,
		method: 'GET'
	})
}

//获取房间信息详情
export const getRoomDetails = (data: any): Promise<ResponseData> => {
	return axios.request({
		url: '/contract/enter_contract/get_enter_contract_houseroom_list',
		data,
		method: 'POST'
	})
}

//获取房间合同详情
export const getRoomContract = (data: any): Promise<ResponseData> => {
	return axios.request({
		url: '/contract/enter_contract/get_enter_contract_child_list',
		data,
		method: 'POST'
	})
}

//查看配置

export const getDispose = (id: string): Promise<ResponseData> => {
	return axios.request({
		url: `/contract/enter_contract/get_enter_contract_payment_config/${id}`,
		method: 'GET'
	})
}

//入住记录
export const getCheckInRecord = (data: any): Promise<ResponseData> => {
	return axios.request({
		url: '/contract/enter_contract/get_enter_contract_check_list',
		data,
		method: 'POST'
	})
}

// 获取房间子合同总数
export const getRoomContractTotal = (data: any): Promise<ResponseData> => {
	return axios.request({
		url: '/contract/enter_contract/get_enter_contract_child_count',
		data,
		method: 'POST'
	})
}

// 分页查询房间信息
export const getRoomListPaging = (data: any): Promise<ResponseData> => {
	return axios.request({
		// url: '/house/house_room_detail/get_houseroom_detail_list_page',
		url: '/contract/enter_contract/house_room/pages',
		data,
		method: 'POST'
	})
}

// 账单抵扣列表
export const billDeductionList = (data: any): Promise<ResponseData> => {
	return axios.request({
		url: '/contract/enter_contract/get_child_deduction_list',
		data,
		method: 'POST'
	})
}

//退组
export const singleRoomReturn = (data: any): Promise<ResponseData> => {
	return axios.request({
		url: '/admin/renter_contract/break_abnormal',
		data,
		method: 'POST'
	})
}

// 查看详情
export const getDetails = (data: any): Promise<ResponseData> => {
	return axios.request({
		url: '/admin/renter_contract/bills',
		data,
		method: 'POST'
	})
}

// 获取企业员工的全部交割单
export const getAllDeliveryOrder = (contractId, deliveryType): Promise<ResponseData> => {
	return axios.request({
		url: `/contract/house_delivery/get_one_renter_info/${contractId}?deliveryType=${deliveryType}`,
		method: 'GET'
	})
}

// 包租合同作废
export const enterContractObsolete = (data: any): Promise<ResponseData> => {
	return axios.request({
		url: '/contract/enter_contract/obsolete',
		method: 'POST',
		data
	})
}

/** 包租合同批量作废 */
export const enterContractBatchObsolete = (data: any): Promise<ResponseData> => {
	return axios.request({
		url: '/contract/enter_contract/batch_obsolete',
		method: 'POST',
		data
	})
}

// 根据业务ID查询退款账单
export const refundBill = (bizId: string): Promise<ResponseData> => {
	return axios.request({
		url: `/finance/finance_bill/get_return_finance_by_biz_id/${bizId}`,
		method: 'GET'
	})
}

// 包租合同批量退租重新提交
export const batchReturnResubmit = (data: any): Promise<ResponseData> => {
	return axios.request({
		url: '/contract/enter_contract/batch_quit_resubmit',
		method: 'POST',
		data
	})
}

/**
 * 入住人数统计
 */
export const getCountEnterContractCheck = (data): Promise<ResponseData> => {
	return axios.request({
		url: '/contract/enter_contract/count_enter_contract_check',
		data,
		method: 'POST'
	})
}

// 包租合同签约前置房源判断
export const validateHouseStatus = (data: object): Promise<ResponseData> => {
	return axios.request({
		url: '/contract/enter_contract/validate_house_status',
		data,
		method: 'POST'
	})
}

// 企业子合同 操作前 查询企业合同审核状态
export const getLastApproval = (businessId: string): Promise<ResponseData> => {
	return axios.request({
		url: `/contract/enter_contract/get/${businessId}`,
		method: 'GET'
	})
}

// 当前企业合同下是否有子合同在审批流
export const hasApproval = (enterContractId: string): Promise<ResponseData> => {
	return axios.request({
		url: `contract/enter_contract/get_child/has_approval/${enterContractId}`,
		method: 'GET'
	})
}

/** 当前企业合同下是否有子合同已续租 */
export const getRenewalContractNum = (id: string): Promise<ResponseData> => {
	return axios.request({
		url: `contract/enter_contract/get_renewal_contract_num/${id}`,
		method: 'GET'
	})
}

// 查询包租合同有入住人
export const isCheckInFun = (id: string): Promise<ResponseData> => {
	return axios.request({
		url: `/contract/enter_contract/has_check_in/${id}`,
		method: 'GET'
	})
}

// 查询企业合同子合同是否有人入住
export const isChildCheckInFun = (id: string): Promise<ResponseData> => {
	return axios.request({
		url: `/contract/enter_contract/get_child/has_check_in/${id}`,
		method: 'GET'
	})
}

// 员工全部搬离
export const allCheckOut = (data: object): Promise<ResponseData> => {
	return axios.request({
		url: '/customer/enter_prise_employee/all_check_out',
		data,
		method: 'POST'
	})
}

// 查询房间费用明细集合
export const searchRoomCostDetail = (data: object): Promise<ResponseData> => {
	return axios.request({
		url: '/basesearch/house/search_by_address/sign',
		data,
		method: 'POST'
	})
}

// 企业预定详情
export const enterHouseBookDetail = (id: string): Promise<ResponseData> => {
	return axios.request({
		url: `/contract/enter_house_book/get/${id}`,
		method: 'GET'
	})
}

// 企业预定退订
export const enterHouseBookBack = (data: object): Promise<ResponseData> => {
	return axios.request({
		url: '/contract/enter_house_book/back',
		data,
		method: 'POST'
	})
}

// 企业预定罚没
export const enterHouseBookConfiscate = (data: object): Promise<ResponseData> => {
	return axios.request({
		url: '/contract/enter_house_book/confiscate',
		data,
		method: 'POST'
	})
}

// 企业预定变更
export const enterHouseBookTransfer = (data: object): Promise<ResponseData> => {
	return axios.request({
		url: '/contract/enter_house_book/transfer',
		data,
		method: 'POST'
	})
}


/** 企业合同是否可以重置 */
export const contractResetValid = (id: string, data: object = {}): Promise<ResponseData> => {
	return axios.request({
		url: `/admin/enter_contract/reset_valid/${id}`,
		data,
		method: 'POST'
	})
}
